﻿using System;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using WindowsPhone_Map_TTTN.Resources;


namespace WindowsPhone_Map_TTTN
{
    public partial class MainPage : PhoneApplicationPage
    {
        private MapModelView main_mv;

        public MainPage()
        {
            InitializeComponent();
            BuildLocalizedApplicationBar();
            main_mv = new MapModelView(this);
            main_mv.initMap();
     
        }
        // Sample code for building a localized ApplicationBar
        private void BuildLocalizedApplicationBar()
        {
            try
            {
                // Set the page's ApplicationBar to a new instance of ApplicationBar.
                ApplicationBar = new ApplicationBar();

                // Create a new button and set the text value to the localized string from AppResources.
                ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("Assets/icons/home.png", UriKind.Relative));
                appBarButton.Text = AppResources.HomeMenu;
                ApplicationBar.Buttons.Add(appBarButton);
                appBarButton.Click += new EventHandler(homeEvent);

                
                ApplicationBarIconButton routing = new ApplicationBarIconButton(new Uri("Assets/icons/home.png", UriKind.Relative));
                routing.Text = AppResources.Route;
                ApplicationBar.Buttons.Add(routing);
                routing.Click += new EventHandler(routingEvent);

                if (MConfig.debug)
                {
                    ApplicationBarIconButton zommin = new ApplicationBarIconButton(new Uri("Assets/icons/home.png", UriKind.Relative));
                    zommin.Text = AppResources.ZoominText;
                    ApplicationBar.Buttons.Add(zommin);
                    zommin.Click += new EventHandler(zoomInEvent);

                    ApplicationBarIconButton zoomout = new ApplicationBarIconButton(new Uri("Assets/icons/home.png", UriKind.Relative));
                    zoomout.Text = AppResources.ZoomoutText;
                    ApplicationBar.Buttons.Add(zoomout);
                    zoomout.Click += new EventHandler(zoomOutEvent);
                }
            }
            catch (Exception ex)
            {
            }
        }

        private void homeEvent(object sender, EventArgs e)
        {
            main_mv.home(sender, e);
        }

        private void routingEvent(object sender, EventArgs e)
        {
            main_mv.routing(sender, e);
        }

        private void zoomOutEvent(object sender, EventArgs e)
        {
            main_mv.zoomOut(sender, e);
        }

        private void zoomInEvent(object sender, EventArgs e)
        {
            main_mv.zoomIn(sender, e);
        }

   }
   
}